안드로이드 Activity 팝업창 만들기!! :: 안드로이드 설치 및 개발[SSISO Community]
 
SSISO 카페 SSISO Source SSISO 구직 SSISO 쇼핑몰 SSISO 맛집
추천검색어 : JUnit   Log4j   ajax   spring   struts   struts-config.xml   Synchronized   책정보   Ajax 마스터하기   우측부분

안드로이드 설치 및 개발
[1]
등록일:2018-07-16 00:00:32 (0%)
작성자:
제목:안드로이드 Activity 팝업창 만들기!!

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="firebase.androidhive.info.tabhost">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Pop"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.DeviceDefault.Light.Dialog">

</activity>
</application>

</manifest>

 

팝업창으로 띄울 액티비티에 위에 표시해놓은 코드를 넣습니다.

 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="500dp"
android:layout_height=
"300dp"
android:orientation="vertical"
android:id="@+id/popupLinearLayout">

<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TabHost
android:id="@+id/tabHost"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="60"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" >

<LinearLayout
android:layout_width="match_parent"

 

띄우고자 하는 xml으로 가서 메인 레이아웃의 width와 height값을 match_parent에서 임의적으로 dp값을 넣습니다.

저는 (500dp, 300dp)를 넣었습니다.

 

 

저는 아래코드에서처럼 메인액티비티에 있는 버튼을 누르면 intent를 주어서 새로운 화면이 뜨도록 만들었습니다.

public class MainActivity extends AppCompatActivity {

Button button;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

button = (Button) findViewById(R.id.mainbutton);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(MainActivity.this, Pop.class));
}
});

}
}

 

 

 

다른 화면을 띄우는 버튼은 임의로 만드시고, 버튼을 눌러 실행하시면

 

 

 

위의 그림처럼 원하던 화면이 팝업창으로 뜨는 것을 보실 수 있을겁니다.



출처: http://charactermail.tistory.com/61?category=754737 [문자메일의 블로그]
[본문링크] 안드로이드 Activity 팝업창 만들기!!
[1]
코멘트(이글의 트랙백 주소:/cafe/tb_receive.php?no=34724
작성자
비밀번호

 

SSISOCommunity

[이전]

Copyright byCopyright ⓒ2005, SSISO Community All Rights Reserved.